/*
============================================================================
 Name        : sd_file.h
 Author      : Jian
 Version     :
 Copyright   : GPL
 Description : sd_file.h - header file
============================================================================
*/

#ifndef SD_FILE_H
#define SD_FILE_H

/* INCLUDES */
#include "dd_define.h"

__DD_BEGIN_DECLS

/*
 * I used the standard C i/o library before,
 * But in symbian the FILE* return by fopen() can not share in multi-thread. 
 * So I have to implement the similar API like standard C
*/

enum {
    DD_FILE_READ = 0,
    DD_FILE_READ_WRITE, 
    DD_FILE_REPLACE
};

enum {
    DD_SEEK_SET = 0,
    DD_SEEK_CUR,
    DD_SEEK_END
};

/* flag must is one of DD_FILE_READ, DD_FILE_READ_WRITE, DD_FILE_REPLACE, and can share in multi-thread */
sd_file* sd_file_open(const DD_UTF8* name, int flag) ;

void sd_file_close(sd_file* file) ;

int sd_file_read(sd_file* file, void* data, DD_UINT len) ;

int sd_file_write(sd_file* file, const void* data, DD_UINT len) ;

int sd_file_tell(sd_file* file) ;

int sd_file_seek(sd_file* file, int offset, int whence) ;

int sd_file_fulsh(sd_file* file) ;

int sd_file_eof(sd_file* file) ;

int sd_file_error(sd_file* file) ;

int  sd_is_file_exist(const DD_UTF8* fileName) ;

int  sd_get_file_size(const DD_UTF8* fileName, DD_UINT* size) ;

int  sd_truncate_file(const DD_UTF8* fileName, DD_UINT size) ;

int  sd_is_folder_exist(const DD_UTF8* folderName) ;

/* create all sub-folder */
int  sd_create_folder(const DD_UTF8* folderName) ;

__DD_END_DECLS

#endif  /* SD_FILE_H */

/* End of File */
